Add DMA handlers to targets
[betaflight.git] / docs / Board - Sparky.md
blobd353fd5258fde427baf10e992ee256dc4ab528ab
1 # Board - Sparky
3 The Sparky is a very low cost and very powerful board.
5 * 3 hardware serial ports.
6 * Built-in serial port inverters which allows S.BUS receivers to be used without external inverters.
7 * USB (can be used at the same time as the serial ports).
8 * 10 PWM outputs.
9 * Dedicated PPM/SerialRX input pin.
10 * MPU9150 I2C Acc/Gyro/Mag
11 * Baro
13 Tested with revision 1 & 2 boards. 
15 ## TODO
17 * Sonar
18 * Display (via Flex port)
19 * SoftSerial - though having 3 hardware serial ports makes it a little redundant.
20 * Airplane PWM mappings.
22 # Voltage and current monitoring (ADC support)
24 Voltage monitoring is possible when enabled via PWM9 pin and current can be monitored via PWM8 pin. The voltage divider and current sensor need to be connected externally. The vbatscale cli parameter need to be adjusted to fit the sensor specification. For more details regarding the sensor hardware you can check here: https://github.com/TauLabs/TauLabs/wiki/User-Guide:-Battery-Configuration
26 # Flashing
28 ## Via Device Firmware Upload (DFU, USB) - Windows
30 These instructions are for flashing the Sparky board under Windows using DfuSE.
31 Credits go to Thomas Shue (Full video of the below steps can be found here: https://www.youtube.com/watch?v=I4yHiRVRY94)
33 Required Software:
34 DfuSE Version 3.0.2 (latest version 3.0.4 causes errors): http://code.google.com/p/multipilot32/downloads/detail?name=DfuSe.rar
35 STM VCP Driver 1.4.0: http://www.st.com/web/en/catalog/tools/PF257938
37 A binary file is required for DFU, not a .hex file.  If one is not included in the release then build one as follows.
39 ```
40 Unpack DfuSE and the STM VCP Drivers into a folder on your Hardrive
41 Download the latest Sparky release (cleanflight_SPARKY.hex) from:
42 https://github.com/cleanflight/cleanflight/releases and store it on your Hardrive
44 In your DfuSE folder go to BIN and start DfuFileMgr.exe
45 Select: "I want to GENERATE a DFUfile from S19,HEX or BIN files" press OK
46 Press: "S19 or Hex.." 
47 Go to the folder where you saved the cleanflight_SPARKY.hex file, select it  and press open
48 (you might need to change the filetype in the DfuSE explorer window to "hex Files (*.hex)" to be able to see the file)
49 Press: "Generate" and select the .dfu output file and location
50 If all worked well you should see " Success for 'Image for lternate Setting 00 (ST..)'!"
52 ```
54 Put the device into DFU mode by powering on the sparky with the bootloader pins temporarily bridged.  The only light that should come on is the blue PWR led.
56 Check the windows device manager to make sure the board is recognized correctly.
57 It should show up as "STM Device in DFU mode" under Universal Serial Bus Controllers
59 If it shows up as "STMicroelectronics Virtual COM" under Ports (COM & LPT) instead then the board is not in DFU mode. Disconnect the board, short the bootloader pins again while connecting the board.
61 If the board shows up as "STM 32 Bootloader" device in the device manager, the drivers need to be updated manually.
62 Select the device in the device manager, press "update drivers", select "manual update drivers" and choose the location where you extracted the STM VCP Drivers, select "let me choose which driver to install". You shoud now be able to select either the STM32 Bootloader driver or the STM in DFU mode driver. Select the later and install.
65 Then flash the binary as below.
67 ```
68 In your DfuSE folder go to BIN and start DfuSeDemo.exe
69 Select the Sparky Board (STM in DFU Mode) from the Available DFU and compatible HID Devices drop down list
70 Press "Choose.." at the bootom of the window and select the .dfu file created in the previous step
71 "File correctly loaded" should appear in the status bar
72 Press "Upgrade" and confirm with "Yes"
73 The status bar will show the upload progress and confirm that the upload is complete at the end
75 ```
77 Disconnect and reconnect the board from USB and continue to configure it via the Cleanflight configurator as per normal
80 ## Via Device Firmware Upload (DFU, USB) - Mac OS X / Linux
82 These instructions are for dfu-util, tested using dfu-util 0.7 for OSX from the OpenTX project.
84 http://www.open-tx.org/2013/07/15/dfu-util-07-for-mac-taranis-flashing-utility/
86 A binary file is required for DFU, not a .hex file.  If one is not included in the release then build one as follows.
88 ```
89 make TARGET=SPARKY clean
90 make TARGET=SPARKY binary
91 ```
93 Put the device into DFU mode by powering on the sparky with the bootloader pins temporarily bridged.  The only light that should come on is the blue PWR led.
95 Run 'dfu-util -l' to make sure the device is listed, as below.
97 ```
98 $ dfu-util -l
99 dfu-util 0.7
101 Copyright 2005-2008 Weston Schmidt, Harald Welte and OpenMoko Inc.
102 Copyright 2010-2012 Tormod Volden and Stefan Schmidt
103 This program is Free Software and has ABSOLUTELY NO WARRANTY
104 Please report bugs to dfu-util@lists.gnumonks.org
106 Found DFU: [0483:df11] devnum=0, cfg=1, intf=0, alt=0, name="@Internal Flash  /0x08000000/128*0002Kg"
107 Found DFU: [0483:df11] devnum=0, cfg=1, intf=0, alt=1, name="@Option Bytes  /0x1FFFF800/01*016 e"
110 Then flash the binary as below.
113 dfu-util -D obj/cleanflight_SPARKY.bin --alt 0 -R -s 0x08000000
116 The output should be similar to this:
119 dfu-util 0.7
121 Copyright 2005-2008 Weston Schmidt, Harald Welte and OpenMoko Inc.
122 Copyright 2010-2012 Tormod Volden and Stefan Schmidt
123 This program is Free Software and has ABSOLUTELY NO WARRANTY
124 Please report bugs to dfu-util@lists.gnumonks.org
126 Opening DFU capable USB device... ID 0483:df11
127 Run-time device DFU version 011a
128 Found DFU: [0483:df11] devnum=0, cfg=1, intf=0, alt=0, name="@Internal Flash  /0x08000000/128*0002Kg"
129 Claiming USB DFU Interface...
130 Setting Alternate Setting #0 ...
131 Determining device status: state = dfuERROR, status = 10
132 dfuERROR, clearing status
133 Determining device status: state = dfuIDLE, status = 0
134 dfuIDLE, continuing
135 DFU mode device DFU version 011a
136 Device returned transfer size 2048
137 No valid DFU suffix signature
138 Warning: File has no DFU suffix
139 DfuSe interface name: "Internal Flash  "
140 Downloading to address = 0x08000000, size = 76764
141 ......................................
142 File downloaded successfully
143 can't detach
144 Resetting USB to switch back to runtime mode
147 On Linux you might want to take care that the modemmanager isn't trying to use your sparky as modem getting it into bootloader mode while doing so. In doubt you probably want to uninstall it. It could also be good idea to get udev fixed. It looks like teensy did just that -> http://www.pjrc.com/teensy/49-teensy.rules (untested)
149 To make a full chip erase you can use a file created by 
151 dd if=/dev/zero of=zero.bin bs=1 count=262144
153 This can be used by dfu-util.
155 ## Via SWD
157 On the bottom of the board there is an SWD header socket onto switch a JST-SH connector can be soldered.
158 Once you have SWD connected you can use the st-link or j-link tools to flash a binary.
160 See Sparky schematic for CONN2 pinouts.
162 ## TauLabs bootloader
164 Flashing cleanflight will erase the TauLabs bootloader, this is not a problem and can easily be restored using the st flashloader tool.
166 # Serial Ports
168 | Value | Identifier   | RX        | TX         | Notes                                                          |
169 | ----- | ------------ | --------- | ---------- | -------------------------------------------------------------- |
170 | 1     | USB VCP      | RX (USB)  | TX (USB)   |                                                                |
171 | 2     | USART1       | RX / PB7  | TX / PB6   | Conn1 / Flexi Port.                                            |
172 | 3     | USART2       | RX / PA3  | PWM6 / PA2 | On RX is on INPUT header.  Best port for Serial RX input       |
173 | 4     | USART3       | RX / PB11 | TX / PB10  | RX/TX is on one end of the 6-pin header about the PWM outputs. |
175 USB VCP *can* be used at the same time as other serial ports (unlike Naze32).
177 All USART ports all support automatic hardware inversion which allows direct connection of serial rx receivers like the FrSky X4RSB - no external inverter needed.
179 # Beeper Connection
181 | Pin  | Signal | Function        |
182 | ---- | ------ | --------------- |
183 | PWM10| PA1    | Beeper Signal   |
185 Output signal to connect a buzzer. Please note this singal can not drive the buzzer, but it must be used to drive for exmaple the gate of a small N-Channel MOSFET, drain connected to the - pin of the buzzer and source to GND. + pin of the buzzer can be conneted to +5 Volts (or even to your Lipo + if the buzzer supports the voltage).
187 # Battery Monitoring Connections
189 | Pin  | Signal | Function        |
190 | ---- | ------ | --------------- |
191 | PWM9 | PA4    | Battery Voltage |
192 | PWM8 | PA7    | Current Meter   |
194 ## Voltage Monitoring
196 The Sparky has no battery divider cricuit, PWM9 has an inline 10k resistor which has to be factored into the resistor calculations.
197 The divider circuit should eventally create a voltage between 0v and 3.3v (MAX) at the MCU input pin.
199 WARNING: Double check the output of your voltage divider using a voltmeter *before* connecting to the FC.
201 ### Example Circuit
203 For a 3Cell battery divider the following circuit works:
205 `Battery (+) ---< R1 >--- PWM9 ---< R2 >--- Battery (-)`
207 * R1 = 8k2 (Grey Red Red)
208 * R2 = 2k0 (Red Black Red)
210 This gives a 2.2k for an 11.2v battery.  The `vbat_scale` for this divider should be set around `52`.
212 ## Current Monitoring
214 Connect a current sensor to PWM8/PA7 that gives a range between 0v and 3.3v out (MAX).